package com.ruoyi.insurance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.insurance.domain.WebSafeIncident;
import com.ruoyi.insurance.service.IWebSafeIncidentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网络安全事件Controller
 * 
 * @author ruoyi
 * @date 2024-08-16
 */
@RestController
@RequestMapping("/insurance/insurance_incident")
public class WebSafeIncidentController extends BaseController
{
    @Autowired
    private IWebSafeIncidentService webSafeIncidentService;

    /**
     * 查询网络安全事件列表
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_incident:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebSafeIncident webSafeIncident)
    {
        startPage();
        List<WebSafeIncident> list = webSafeIncidentService.selectWebSafeIncidentList(webSafeIncident);
        return getDataTable(list);
    }

    /**
     * 导出网络安全事件列表
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_incident:export')")
    @Log(title = "网络安全事件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WebSafeIncident webSafeIncident)
    {
        List<WebSafeIncident> list = webSafeIncidentService.selectWebSafeIncidentList(webSafeIncident);
        ExcelUtil<WebSafeIncident> util = new ExcelUtil<WebSafeIncident>(WebSafeIncident.class);
        util.exportExcel(response, list, "网络安全事件数据");
    }

    /**
     * 获取网络安全事件详细信息
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_incident:query')")
    @GetMapping(value = "/{incidentId}")
    public AjaxResult getInfo(@PathVariable("incidentId") Integer incidentId)
    {
        return success(webSafeIncidentService.selectWebSafeIncidentByIncidentId(incidentId));
    }

    /**
     * 新增网络安全事件
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_incident:add')")
    @Log(title = "网络安全事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebSafeIncident webSafeIncident)
    {
        return toAjax(webSafeIncidentService.insertWebSafeIncident(webSafeIncident));
    }

    /**
     * 修改网络安全事件
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_incident:edit')")
    @Log(title = "网络安全事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebSafeIncident webSafeIncident)
    {
        return toAjax(webSafeIncidentService.updateWebSafeIncident(webSafeIncident));
    }

    /**
     * 删除网络安全事件
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_incident:remove')")
    @Log(title = "网络安全事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{incidentIds}")
    public AjaxResult remove(@PathVariable Integer[] incidentIds)
    {
        return toAjax(webSafeIncidentService.deleteWebSafeIncidentByIncidentIds(incidentIds));
    }
}
